package com.windea.study.kotlin.jvm.crypt

import kotlin.test.*

class Tests {
	//获取字符的ASCII编码
	fun getASCII() {
		val char = 'c'
		val value = char.toInt()
		println(value)
	}
	
	//获取字符串的ASCII编码
	fun getASCIIOfString() {
		val str = "hello world"
		val value = str.toCharArray().map { it.toInt() }
		println(value)
	}
	
	fun getASCIIOfStringOneLine() {
		val str = "hello world"
		val value = str.toCharArray().map { it.toInt() }.joinToString(" ")
		println(value)
	}
	
	
	//转化为二进制字符串
	@ExperimentalStdlibApi
	@Test
	fun toBiString() {
		val num = 111
		println(num.countOneBits())
		println(num.toByte())
		println(num.toShort())
		//将数字转化成二进制字符串
		println(Integer.toBinaryString(num))
		println(Integer.toHexString(num))
		println(Integer.toOctalString(num))
	}
}
